/*
*	Copyright (C) 2014  Julio Montes, Mario Carrillo
*	
*	Julio Montes e-mail: imc.coder@gmail.com 
*
*	Mario Carrillo e-mail: mario_90ago@live.com.mx
*
*	BSD 3-Clause License
*/

#include "include/iaFindDialogBase.h"

BEGIN_EVENT_TABLE( iaFindDialogBase, wxDialog )
    EVT_CHECKBOX( iaID_FDBASE_CBREGEXP, iaFindDialogBase::OnRegExp )
END_EVENT_TABLE()

iaFindDialogBase::iaFindDialogBase( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize &size )
    : wxDialog( parent, id, title, position, size )
{
    bsMain = new wxBoxSizer( wxVERTICAL );
    wxBoxSizer *bsHOptions = new wxBoxSizer( wxHORIZONTAL );
    wxBoxSizer *bsVOptions = new wxBoxSizer( wxVERTICAL );

    bsInputText = new wxBoxSizer( wxVERTICAL );
    stFind = new wxStaticText( this, wxID_ANY, wxT( "Text to search: " ) );
    cbFind = new wxComboBox( this, iaID_FDBASE_CBFIND, wxT( "" ), wxDefaultPosition, wxDefaultSize, 0, NULL, wxTE_PROCESS_ENTER );

    bsInputText->Add( stFind, 0, wxEXPAND | wxLEFT | wxRIGHT | wxTOP, 20 );
    bsInputText->AddSpacer( 5 );
    bsInputText->Add( cbFind, 0, wxEXPAND | wxLEFT | wxRIGHT, 20 );

    bsMain->Add( bsInputText, 0, wxEXPAND );

    wxStaticBoxSizer *sbsOptions = new wxStaticBoxSizer( wxVERTICAL, this, wxT( " Options " ) );
    cbMatchCase = new wxCheckBox( this, wxID_ANY, wxT( "Match case" ) );
    cbRegExp = new wxCheckBox( this, iaID_FDBASE_CBREGEXP, wxT( "Regular expresion" ) );
    cbPosixRegExp = new wxCheckBox( this, wxID_ANY, wxT( "Posix in RegExp" ) );
    cbAutoWrap = new wxCheckBox( this, wxID_ANY, wxT( "Auto-wrap at EOF" ) );
    cbAutoWrap->SetValue( true );
    cbWholeWord = new wxCheckBox( this, wxID_ANY, wxT( "Whole word" ) );
    cbStartWord = new wxCheckBox( this, wxID_ANY, wxT( "Start word" ) );

    sbsOptions->Add( cbMatchCase, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );
    sbsOptions->Add( cbRegExp, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );
    sbsOptions->Add( cbPosixRegExp, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );
    sbsOptions->Add( cbAutoWrap, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );
    sbsOptions->Add( cbWholeWord, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );
    sbsOptions->Add( cbStartWord, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );

    bsHOptions->Add( sbsOptions, 1, wxEXPAND | wxLEFT | wxRIGHT, 10 );




    wxStaticBoxSizer *sbsOrigin = new wxStaticBoxSizer( wxVERTICAL, this, wxT( " Origin " ) );
    rbFromCursor = new wxRadioButton( this, wxID_ANY, wxT( "From cursor" ), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
    rbStartFile = new wxRadioButton( this, wxID_ANY, wxT( "Beginning of file" ) );

    sbsOrigin->Add( rbFromCursor, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );
    sbsOrigin->Add( rbStartFile, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );
    bsVOptions->Add( sbsOrigin, 0, wxEXPAND );







    wxStaticBoxSizer *sbsScope = new wxStaticBoxSizer( wxVERTICAL, this, wxT( " Scope " ) );
    rbGlobal = new wxRadioButton( this, wxID_ANY, wxT( "Global" ), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
    rbSelectText = new wxRadioButton( this, wxID_ANY, wxT( "Select text" ) );

    sbsScope->Add( rbGlobal, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );
    sbsScope->Add( rbSelectText, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );
    bsVOptions->Add( sbsScope, 0, wxEXPAND | wxTOP, 15 );






    sbsDirection = new wxStaticBoxSizer( wxVERTICAL, this, wxT( " Direction " ) );
    rbUp = new wxRadioButton( this, wxID_ANY, wxT( "Up" ), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
    rbDown = new wxRadioButton( this, wxID_ANY, wxT( "Down" ) );
    rbDown->SetValue( true );

    sbsDirection->Add( rbUp, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );
    sbsDirection->Add( rbDown, 0, wxEXPAND | wxLEFT | wxRIGHT, 10 );
    bsVOptions->Add( sbsDirection, 0, wxEXPAND | wxTOP, 15 );

    bsHOptions->Add( bsVOptions, 1, wxEXPAND | wxLEFT | wxRIGHT, 10 );

    bsMain->Add( bsHOptions, 1, wxEXPAND | wxTOP, 20 );


    SetSizer( bsMain );
}

iaFindDialogBase::~iaFindDialogBase()
{

}


void iaFindDialogBase::OnRegExp( wxCommandEvent &evt )
{
    rbDown->Enable( !evt.IsChecked() );
    rbUp->Enable( !evt.IsChecked() );
}
